package com.example.app.manager

import android.content.Context
import android.content.Intent
import android.net.Uri
import com.blankj.utilcode.util.AppUtils


/**
 * CreateBy:Joker
 * CreateTime:2024/10/23/周三 17:56
 * description：
 */
object GooglePlayManager {

    /**
     * 跳转google play
     */
    fun openGooglePlay(context: Context) {
        val playPackage = "com.android.vending"
        try {
            val currentPackageUri = Uri.parse("market://details?id=${AppUtils.getAppPackageName()}")
            val intent = Intent(Intent.ACTION_VIEW, currentPackageUri)
            intent.setPackage(playPackage)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        } catch (e: Exception) {
            e.printStackTrace()
            val currentPackageUri = Uri.parse("https://play.google.com/store/apps/details?id=${AppUtils.getAppPackageName()}")
            val intent = Intent(Intent.ACTION_VIEW, currentPackageUri)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }
}